package com.eogo.merchant.service.impl;

import com.eogo.merchant.mapper.MerchantMapper;
import com.eogo.merchant.pojo.Merchant;
import com.eogo.merchant.service.MerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MerchantServiceImpl implements MerchantService {

    @Autowired
    private MerchantMapper merchantMapper;

    @Override
    public void insertMerchant(Merchant merchant) {
        merchant.setAudit(1);//提交成功
        merchant.setSoldout(1);//正常
        merchantMapper.insert(merchant);
    }

    @Override
    public void updateMerchant(Merchant merchant) {
        merchantMapper.updateByPrimaryKeySelective(merchant);
    }

    @Override
    public Merchant queryMerchantById(Long id) {
        return merchantMapper.selectByPrimaryKey(id);
    }

    @Override
    public void updateMerchantByAudit(Long id, Integer audit) {
        Merchant merchant = new Merchant();
        merchant.setId(id);
        merchant.setAudit(audit);
        merchantMapper.updateByPrimaryKeySelective(merchant);
    }

    @Override
    public void updateMerchantBySoldout(Long id, Integer soldout) {
        Merchant merchant = new Merchant();
        merchant.setId(id);
        merchant.setSoldout(soldout);
        merchantMapper.updateByPrimaryKeySelective(merchant);
    }
}
